home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- /*
- * Copyright (C) 1991, Silicon Graphics, Inc.
- * All Rights Reserved.
- */
-
- /*
- * midif - MIDI file format definitions
- *
- * Jim Bennett
- * 1991
- */
-
- #define INSTRUMENTS 16 /* Number of instruments */
- #define MAX_VOICES 32 /* Maximum number of voices */
-
- #define WFTABL 720 /* Length of waveform tables */
- #define WF_REPLICATION 30 /* Replication factor for waveform */
-
- #define MIDDLE_C 60
- #define A_ABOVE (MIDDLE_C+9)
- #define A_HZ 440
-
- #define SYNTHIA_RATE AL_RATE_32000
- #define SAMPLE_BUFSIZE (SYNTHIA_RATE/10)
-
- #define MF_header "MThd"
- #define MF_track "MTrk"
-
- struct s_mfhd
- {
- int format;
- int ntrks;
- int division;
- };
-
- /*
- * MIDI event structure: time (in seconds) and event code
- *
- * The 32-bit event code is structured as follows:
- * bits 0- 7: pitch
- * bits 8-15: velocity
- * bits 16-23: event code (note on or off)
- * bits 24-27: program
- * bits 28-31: finger
- */
-
- struct s_mfevent
- {
- float time;
- long event;
- };
-
- #define END_TIME 1.0e+30
- #define LONG_TIME 1.0e+20
-
- /*
- * MIDI file events
- */
-
- #define META_EVENT 0xff
- #define SYSEX_EVENT 0xf0
- #define SYSEX_EVENTA 0xf7
-
- /*
- * META event types
- */
-
- #define END_TRACK 0x2f
-
- /*
- * MIDI status bytes
- */
-
- #define NOTE_OFF 0x80
- #define NOTE_ON 0x90
- #define KEY_PRESSURE 0xa0
- #define PARAMETER 0xb0
- #define PROGRAM 0xc0
- #define CHAN_PRESSURE 0xd0
- #define PITCH_WHEEL 0xe0
-
- /*
- * Per track structure for playing tracks
- */
-
- #define MAX_TRACKS 32 /* Maximum number of tracks */
- #define MAX_FINGERS 16 /* Maximum fingers per track */
-
- /*
- * First must define per finger structure
- */
-
- struct s_finger
- {
- struct s_voice *vp; /* Voice pointer */
- int note; /* Pitch of current note */
- int wl; /* Wavelength of current tone */
- float wlis; /* Wavelength index scale */
- float atten; /* Waveform attenuation */
- float catten; /* Complement of above */
-
- float *aeptr; /* Amplitude envelope pointer */
- int wli; /* Wavelength index */
- float t; /* Time into amplitude envelope */
- float val; /* Current value of amplitude */
- float vdel; /* Current amplitude delta */
-
- int finger; /* Finger number */
- int track; /* Track for this finger */
- float *wftab; /* Waveform table */
- };
-
- struct s_ptrk
- {
- struct s_mfevent *base; /* This track's events */
- struct s_mfevent *evptr;
- float *on_amp_env; /* Amplitude envelope/keydown */
- float *off_amp_env; /* Amplitude envelope/keyup */
- int nfingers; /* Max number of fingers */
- struct s_finger f[2*MAX_FINGERS]; /* Finger state for this track */
- };
-
- /*
- * Currently active voice structure
- */
-
- struct s_voice
- {
- struct s_finger *fp;
- int keydown;
- struct s_voice *next;
- };
-